﻿<UserControl x:Class="BBInterfaceNET.PropertiesWindow.Views.PropertiesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:in="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:b="clr-namespace:BBInterfaceNET.PropertiesWindow.Behaviors"
             xmlns:swf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
             xmlns:conv="clr-namespace:BBInterfaceNET.PropertiesWindow.Converters"
             mc:Ignorable="d" Margin="0" Background="LightGray"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:NullToVisibilityConverter x:Key="conv" Collapsed="True"/>
        <conv:NullToVisibilityConverter x:Key="invConv" Inverse="True" Collapsed="True"/>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Background="DarkBlue">
            <TextBlock Text="Properties" Foreground="White"
                       Margin="5,2" FontWeight="Bold"/>
        </Border>
        
        <TextBlock Grid.Row="1" Padding="10,4" Background="WhiteSmoke"
                   Visibility="{Binding SelectedField, Converter={StaticResource conv}}"
                   >
            <TextBlock Text="{Binding SelectedField}" />
            <TextBlock Foreground="Gray" Margin="2,0">
                <TextBlock Text="&lt;" Visibility="{Binding Path=SelectedField.Name, Converter={StaticResource invConv}}" />
                <TextBlock Text="{Binding Path=SelectedField.Name, TargetNullValue='no name'}"/>
                <TextBlock Text=">" Visibility="{Binding Path=SelectedField.Name, Converter={StaticResource invConv}}" />
            </TextBlock>
            
        </TextBlock>
        <in:WindowsFormsHost DataContext="{Binding SelectedField}" MinWidth="100" 
                             MaxWidth="200" Grid.Row="2">
            <i:Interaction.Behaviors>
                <b:WFHostBehavior/>
            </i:Interaction.Behaviors>
            <in:WindowsFormsHost.Child>
                <swf:PropertyGrid Dock="Fill" />
            </in:WindowsFormsHost.Child>
        </in:WindowsFormsHost>
    </Grid>
</UserControl>
